-- Copypasta'd from TTT -- sorry guys!

GM.TagPredicates = {
	["mstr:version"] =
		function(gm) return "mstr:v"..gm.VersionTag end,
		
	["mstr:custom_weapons"] =
		function(gm) return gm.CustomWeapons end,
		
	["mstr:longrounds"] =
		function(gm) return cvars.Number( "ms_round_timer", 3 )>4 end,
		
	["mstr:nomapchange"] =
		function(gm) return (cvars.Number( "ms_map_length", 10 )<0 and cvars.Number( "ms_map_winlimit", 10 )<0) end
		
	
}

function GM:UpdateServerTags(remove_only)

   local tags_old = GetConVarString("sv_tags")

   -- Strip out any tags we might have added before
   tags_old = string.gsub(tags_old, "(,ttt:[^,]*)", "")
   Dev(1, "Old tags: " .. tags_old)

   -- Generate new tag list
   local tags_new = ""
   if not remove_only then
      for tag, pred in pairs(self.TagPredicates) do
         local t = pred(self)
         if t then
            tags_new = tags_new .. "," .. (type(t) == "string" and t or tag)
         end
      end
      Dev(1, "Adding to sv_tags: " .. tags_new)
   end

   RunConsoleCommand("sv_tags", tags_old .. tags_new)
end